<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>清单统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <script type="text/javascript" src="../../layuiadmin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../layuiadmin/layui/xadmin.js"></script>
    <script type="text/javascript" src="../../layuiadmin/js/system/jquery.min.js"></script>
    <script src="../../layuiadmin/js/system/jquery.cookie.js"></script>
    <script>
        $(function () {
            var hrName = $("#hrName");
            $.post("http://localhost:8080/user/getByName",
                function (msg) {
                    for (var i = 0; i < msg.length; i++) {
                        var option = $("<option value=" + msg[i].empId + ">" + msg[i].empName + "</option>");
                        hrName.append(option);
                        layui.use('form', function () {
                            var form = layui.form;
                            form.render("select");
                        });
                    }
            })
        })
    </script>
</head>
<body>
<div class="layui-form" id="form">
    <div class="demoTable">
<div class="layui-form" wid100 id="divData" style="margin-top: 10px">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">员工名称:</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" lay-search="" id="hrName">
                    <option value="-1"></option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">日期范围</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="test-laydate-range-date" placeholder=" - ">
            </div>
        </div>
        <button class="layui-btn" data-type="reload" type="button">搜索</button>

        <button class="layui-btn layui-btn-primary layui-btn-radius" data-type="reload" style="margin-left: 120px" value="1" onclick="btn(this)">近一个月</button>
        <button class="layui-btn layui-btn-primary layui-btn-radius" data-type="reload" value="3" id="btn1" onclick="btn(this)">近三个月</button>
        <button class="layui-btn layui-btn-primary layui-btn-radius" data-type="reload" value="6" onclick="btn(this)">近半年</button>
        <button class="layui-btn layui-btn-primary layui-btn-radius" data-type="reload" value="12" onclick="btn(this)">近一年</button>
    </div>
    <h1 style="margin-left: 500px">***律师事务所执业人员财务清单</h1>
                <div class="layui-card">
                    <div class="layui-card-header"></div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="test-table-simple">律师创收</table>
                    </div>
                    <div class="layui-card-header" id="divTest">律师创收提成</div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="table2"></table>
                    </div>
                </div>
            </div>
        </div>
</div>
<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'laydate'], function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#test-laydate-range-date'
            ,range: true
        });
    });
</script>
<script>
    var time2;
    function btn(obj){
        time2=obj.value;
        var time=$("#test-laydate-range-date").val("");
    }
    function createrFormat(o){
        return o;
    }
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test-table-simple'
            ,totalRow:true
            ,url: 'http://localhost:8080/finStatistics/finaceIncome'
            ,cellMinWidth: 100 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [[
                {field:'emp_name', title: '承办律师', totalRowText:'合计:'}
                ,{field:'case_id',  title: '案号'}
                ,{field:'clientname1',  title: '委托人', sort: true}
                ,{field:'clientname2',  title: '对方当事人'}
                ,{field:'collection_date', title: '收款日期'}
                ,{field:'collection_money', title: '收款金额', totalRow:true}
                ,{field:'remark', title: '备注',minwidth:150, sort: true}
            ]]
            ,id:'table'
        });
        table.render({
            elem: '#table2'
            ,totalRow:true
            ,url: 'http://localhost:8080/finStatistics/finaceIncome'
            ,cellMinWidth: 100 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [[
                {field:'emp_name', title: '承办律师', totalRowText:'合计:'}
                ,{field:'case_id',  title: '案号'}
                ,{field:'clientname1',  title: '委托人', sort: true}
                ,{field:'clientname2',  title: '对方当事人'}
                ,{field:'creat_income', title: '创收金额', sort: true}
                ,{field:'actual_money', title: '实际提成',minwidth:150, totalRow:true}
            ]]
            ,id:'table1'
        });
        var $=layui.$,active={
            reload:function () {
                var hrName=$("#hrName").val();
                var time=$("#test-laydate-range-date").val();
                //执行重载
                table.reload('table',{
                    where:{
                        empId:hrName,
                        time:time,
                        time3:time2
                    }
                },'data');

                table.reload('table1',{
                    where:{
                        empId:hrName,
                        time:time,
                        time3:time2
                    }
                },'data');
            }
        }
        $('.demoTable .layui-btn').on('click',function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        })

    });
</script>
</body>
</html>